//  This file is part of Swordbible - http://www.swordwarrior.net
//  Copyright (C) 2003-2009 Manu Mital mital.manu@gmail.com

//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2, or (at your option)
//  any later version.

//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.

//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software Foundation,
//  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Remove.cpp : implementation file
//

#include <stdafx.h>
#include "SwordBible.h"
#include "Remove.h"


// CRemove dialog



IMPLEMENT_DYNAMIC(CRemove, CDialog)

CRemove::CRemove(CWnd* pParent /*=NULL*/)
	: CDialog(CRemove::IDD, pParent)
{

}

CRemove::~CRemove()
{
}

void CRemove::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_TREE_REMOVE, treeCtrl);
}


BEGIN_MESSAGE_MAP(CRemove, CDialog)
	ON_BN_CLICKED(IDOK, &CRemove::OnOk)
END_MESSAGE_MAP()


// CRemove message handlers

void CRemove::OnOk()
{
	HTREEITEM tItem = treeCtrl.GetRootItem();
	modList = _T("");
	
	if(type == _T("multiple"))
		while(tItem != NULL)
		{	
			if( !treeCtrl.GetCheck(tItem) ) modList += treeCtrl.GetItemText(tItem) + _T(", ");		
			tItem = treeCtrl.GetNextSiblingItem(tItem);
		}


	else if(type == _T("single"))
	{
		tItem = treeCtrl.GetSelectedItem();
		if(tItem) modList = treeCtrl.GetItemText(tItem);
		
	}



	OnOK();
}


// CDeleteVerses message handlers
BOOL CRemove::OnInitDialog()
{
	CDialog::OnInitDialog();

	HICON icon_file;

	if(icon == _T("file"))
	icon_file = ::AfxGetApp()->LoadIcon(IDI_ICON_FILE);

	else if(icon == _T("folder"))
	icon_file = ::AfxGetApp()->LoadIcon(IDI_ICON_FOLDER);
	

	m_image.Create(16,16, ILC_COLORDDB ,0,1);
	m_image.SetBkColor(RGB(255,255,255));
	m_image.Add(icon_file);


	treeCtrl.SetImageList(&m_image, TVSIL_NORMAL );

	// add background effect
	treeCtrl.SetBkColor( RGB(245,255,255));


	if(type == _T("multiple")) // using check boxes to select multiple selection
	treeCtrl.ModifyStyle(NULL, treeCtrl.GetStyle()|TVS_SHOWSELALWAYS|
			TVS_DISABLEDRAGDROP | TVS_CHECKBOXES );

	if(type == _T("single")) 
		treeCtrl.ModifyStyle(TVS_CHECKBOXES, treeCtrl.GetStyle()|TVS_SHOWSELALWAYS|
			TVS_DISABLEDRAGDROP );

	// add strings to the tree control
	int count = arr.GetCount();
	FirstItem = NULL;

	if(count) FirstItem = treeCtrl.InsertItem(arr.GetAt(0));


	for(int i = 1; i < count; i++)		
		treeCtrl.InsertItem(arr.GetAt(i));

  return TRUE;
}
